<template>
  <div>
    <multiple-area v-if="multiple" v-model="cloneValue" :clearable="clearable" :show-level="showLevel" :reload="reload" :placeholder="placeholder" :check-strictly="checkStrictly" @change="onChange"></multiple-area>
    <single-area v-if="!multiple" v-model="cloneValue" :clearable="clearable" :show-level="showLevel" :reload="reload" :placeholder="placeholder" :check-strictly="checkStrictly" @change="onChange"></single-area>
  </div>
</template>

<script>
import MultipleArea from './Multiple'
import SingleArea from './Single'

export default {
  components: { MultipleArea, SingleArea },
  props: {
    value: {
      type: [Object, Array],
      default: () => {
        return {}
      }
    },
    clearable: {
      type: Boolean,
      default: true
    },
    showLevel: {
      type: Number,
      default: 2,
      validator (value) {
        return [1, 2, 3].includes(value)
      }
    },
    reload: {
      type: Boolean,
      default: false
    },
    placeholder: {
      type: String,
      default: '请选择所在地区'
    },
    checkStrictly: {
      type: Boolean,
      default: false
    },
    multiple: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {}
  },
  computed: {
    cloneValue: {
      get () {
        return this.value
      },
      set (val) {
        this.$emit('input', val)
      }
    }
  },
  watch: {},
  created () { },
  mounted () { },
  methods: {
    onChange (data) {
      this.$emit('change', data)
    }
  }
}
</script>

<style>
</style>
